package com.zbkj.admin.controller.mszs;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.*;
import com.zbkj.common.request.mszs.MsusUserSearchRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.UserResponse;
import com.zbkj.service.service.user.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 用户表 前端控制器
 * JIANTAO
 */
@Slf4j
@RestController
@RequestMapping("api/admin/mszs/user")
@Api(tags = "会员管理")
@Validated
public class MszsUserController {
    @Autowired
    private UserService userService;

    /**
     * 分页显示用户表
     * @param request 搜索条件
     * @param pageParamRequest 分页参数
     */
    @PreAuthorize("hasAuthority('admin:user:list')")
    @ApiOperation(value = "分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<UserResponse>> getList(@ModelAttribute @Validated MsusUserSearchRequest request,
                                                          @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<UserResponse> userCommonPage = CommonPage.restPage(userService.getMszsUsers(request, pageParamRequest));
        return CommonResult.success(userCommonPage);
    }

}



